home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
nt107.zip
/
KEYBOARD.DOC
< prev
next >
Wrap
Text File
|
1980-01-01
|
8KB
|
144 lines
ntekb: nterm's Extended Keyboard handler
====== =================================
Nevil Brownlee
Computer Centre, University of Auckland
Mon 4 July 88
For a long time now nterm users have asked me 'Why can't you map the PC's
numeric keyboard like a DEC one?' and 'Can't you do something which will make
the IBM Enhanced keyboard (with the function keys along the top) easier to use
with nterm?'
I didn't do this initially since it would have involved writing a keyboard
interrupt handler. Instead I simply used the BIOS handler. That provided
several advantages, i.e.
- It was simpler to write and debug (it's hard to use debug to look at
a keyboard interrupt routine, since you don't have a keyboard for
DEBUG any more).
- It works on any machine which implements BIOS properly.
- It allows you to use memory-resident routines which 'hook' the
keyboard interrupts, e.g. mouse drivers and keyboard mappers.
The new handler is an attempt to provide key mappings which use the PC
keyboard better, without giving away the second two advantages. Its design
aims were
- To continue using the BIOS key mappings wherever this was possible,
so as to allow earlier versions of the nterm Terminal Definition (.TDF)
files to be used unchanged.
- To provide new mappings for keys which BIOS doesn't (e.g. Sys Req on
the AT, F11, F12, Enter etc. on the Enhanced keyboard).
- To provide a set of mappings allowing the numeric keypad to be used
as a DEC alternate keyboard, including the ability to implement
Application Key and Cursor Key modes.
- To work properly with the original PC keyboard, the AT keyboard and the
'Enhanced' keyboard, without requiring the user to specify which kind of
keyboard is being used.
- To automatically determine whether the keyboard LEDs can be controlled
(i.e. whether we have an AT keyboard), and if possible set the keyboard
LEDs to correctly indicate the shift status.
The handler is implemented in two parts; a set of routines in ntekb.asm which
does the actual interrupt handling, and a translate routine in ntntr.c which
translates the keyboard codes into nterm key codes.
When a keyboard interrupt is received the keyboard scan code is read. If it
was a shift key the shift status is updated, the scan code and shift status
are placed in the nterm keyboard buffer, then the interrupt is passed on to
BIOS to be handled as usual. The translate routine looks to see whether there
is a key code in nterm's keyboard buffer. If there's also one in the BIOS
keyboard buffer the buffer is emptied and the BIOS scan code translations are
used. This allows nterm to use the nterm keyboard buffer as a signal that a
key has been pressed, and then pick up all the characters placed in the BIOS
buffer by a 'hook' routine such as a mouse driver. Note that the system
overhead in inspecting the nterm buffer pointers is considerably less than
that in using a BIOS interrupt to check the BIOS keyboard buffer.
Some key codes are not passed to BIOS; these are the ones which I believe to
be 'dangerous' to nterm. For example the Print Screen key can ask BIOS to
dump the screen to a local printer - but if there isn't a printer I don't know
any way (except rebooting the system) to stop BIOS waiting indefinitly for the
printer to become ready! Control-Num Lock stops BIOS dead, busy waiting for
another Control-Num Lock. And so on.
To allow the 'DEC keypad' mapping I decided to use Num Lock to enter 'DEC
keypad' mode. In this mode the Num Lock key (in the DEC keypad's PF2
position) maps to 'PF2', and therefore can't be used to leave this shift
state. To return to normal you use Shift-Num Lock. On the AT keyboard ntekb
sets the keyboard LEDs to indicate the shift status, and the 'shift key' codes
are not passed to BIOS.
To cope with the original PC keyboard, which has double-width Num Lock and
Scroll Lock keys as well as a triple-height Grey + key, ntekb maps Alt-Num
Lock, Alt-Scroll Lock and Alt-Grey + to key codes which can be used instead of
the AT Esc (left of Num Lock), Sys Req (right of Scroll Lock) and Grey *
(above Grey -). This provides a usable alternate keypad; the only anomoly is
that the Grey - and + keys on the original PC keypad are thus 'upside down'
compared to where they are on the AT.
The PC keyboard also has the problem that it doesn't have keyboard LEDs.
Actually there is no problem if it really doesn't have LEDs, but many of them
do and those LEDs are just toggled by the Num Lock, Scroll Lock and Caps Lock
keys. Since the toggling is done in the keyboard itself there's nothing nterm
can do to prevent it - instead I've implemented a 'display shift state'
option, which displays the shift status in the lower right-hand corner of the
screen.
The Enhanced keyboard has problems of its own; it does have extra keys, and
some of these send new scan codes which BIOS ignores. Others send the same
scan codes as earlier keys, preceded by a code indicating that an 'enhanced'
key has been pressed. ntekb sorts out this mess, and presents the translate
routine with enough information to map the key to its proper nterm key code.
nterm's key codes have been chosen so as to achieve the design aims stated
above. To find out which scan code goes with which key you can either use
kpc's SHOW KEY command - which will tell you the code so you can SET KEY to
map it to something else - or you can look at the source code for ntvt.c,
which has a complete list of all the nterm key codes.
Compatibility with earlier versions of .TDF files provided some problems too.
To provide extra mappable keys for v200.tdf I had used Shifted numeric keypad
keys, but for ntekb these must simply produce the normal shifted key code.
One can't use Alt-numeric keypad keys, since BIOS uses these to form an input
decimal code, e.g. Alt-3,2 produces the ASCII character '2' when the Alt key
is released. I therefore had to use Control-numeric keys for ntekb, so the
codes formerly produced by Shift-numeric keys are now produced by Control-
numerics, e.g. Control-End produces LF, etc. One special case of this is that
Control-Print Screen must be pressed to get a printer screen dump.
Another compatibility issue is that when using an old version of .TDF file
such as v200.tdf, one will get a set of digits from the Shifted (or Num
Locked) numeric keypad keys. This is achieved for the '0'..'9', '.', '+' and
'-' keys, which appear in their expected places.
One last piece of confusion: when using vt.tdf, the Grey *, - and + keys
produce the characters *, - and + when they are unshifted. But when they are
shifted they produce the DEC alternate keypad characters ',', '+' and 'Enter'!
Although all this sounds confusing, in practice it seems to work very well. I
find it most convenient to leave the numeric keypad unshifted, so that the
arrow keys (which I use a lot) will move the cursor. When I want an Alternate
Keypad key I have to hold down the shift key, but then I don't use these keys
nearly as much as I use the arrow keys. The other unshifted keys map the DEC
editing, Help and Do keys; this also seems to work well. Should I wish to
enter a lot of numeric data, Num Lock lets me do it. Finally the function
keys; with a good Alternate Keypad mapping these don't get used very often at
all when working under VMS. They can therefore either be ignored, or can be
mapped to user-chosen strings using SET KEY.
I would appreciate hearing any comments you may have about nterm's new
keyboard mapping.